/**
* @file qousermodel.cpp
* @describe QoUserModel
* @author gaoyuelong
* @date 2022/05/04
*/

#include "qousermodel.h"
#include "network/qotcp.h"

#include <QJsonObject>
#include <QJsonDocument>

QoUserModel::QoUserModel()
{
    connect(QoTcp::getInstance(), SIGNAL(signalRecvMsg()), this, SLOT(slotRecvMsg()));
}

void QoUserModel::sendMsg(const QJsonObject &jsonObj)
{
    //先发送登录信息
    QoTcp::getInstance()->sendMsg(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact)));

//    //等待返回消息
//    QJsonObject recvMsgJsonObj;
//    QoTcp::getInstance()->recvMsg(recvMsgJsonObj);
//    return recvMsgJsonObj;
}

void QoUserModel::slotRecvMsg()
{
    QJsonObject recvMsgJsonObj;
    QoTcp::getInstance()->recvMsg(recvMsgJsonObj);
    emit signalRecvMsg(recvMsgJsonObj);
}
